import win32gui

class WindowActivate:
    @staticmethod
    def activate_window(hwnd):
        """激活指定句柄的窗口"""
        try:
            win32gui.ShowWindow(hwnd, 1)  # 显示窗口
            win32gui.SetForegroundWindow(hwnd)  # 将窗口置于前台
            return True
        except Exception as e:
            print(f"激活窗口失败: {e}")
            return False 